﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace KTDS_PING_CHECK
{
    public partial class UI_PING_CHECK : UserControl
    {
        C_Ping ping = new C_Ping();

        public UI_PING_CHECK()
        {
            InitializeComponent();
        }

        private void btn_SinglePingCheck_Click(object sender, EventArgs e)
        {
            string IpInfo = txb_SingleIp.Text;

            if (IpInfo.Length != 0)
            {
                //정표 표현식으로 IP 형식이 맞는지 검증 필요!!!

                if (ping.CheckThePing(IpInfo))
                {
                    txb_SingleIpResult.Text = IpInfo + ",Success";
                }
                else
                {
                    txb_SingleIpResult.Text = IpInfo + ",TimeOut";
                }
            }
        }

        private void btn_MultiPingCheck_Click(object sender, EventArgs e)
        {
            String[] arrIP = txb_MultiIpResult.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None);

            txb_MultiIpResult.Clear();

            for (int i = 0; i < arrIP.Length; i++)
            {
                if (ping.CheckThePing(arrIP[i]))
                {
                    txb_MultiIpResult.Text += arrIP[i].ToString() + ",Success" + Environment.NewLine;
                }
                else
                {
                    txb_MultiIpResult.Text += arrIP[i].ToString() + ",TimeOut" + Environment.NewLine;
                }
            }
        }
    }
}
